<template>
    <header class="header">
      <h1>小黑记事本</h1>
      <input @keyup.enter="handleAdd" placeholder="请输入任务" class="new-todo" v-model="msg" />
      <button @click="handleAdd" class="add">添加任务</button>
    </header>
</template>

<script>
export default {
data(){
  return {
    msg:''
  }
},
methods:{
  handleAdd(){
    if(this.msg.trim()===''){
      alert('请输入内容')
      return
    }

// console.log(this.msg)
this.$emit('add',this.msg)
  }
}
}
</script>

<style>

</style>